package com.ougy.reshop.action;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import com.opensymphony.xwork2.ModelDriven;
import com.ougy.reshop.model.User;
import com.ougy.reshop.util.Notice;
import com.ougy.reshop.vo.UserRegisterInfo;


@Component("register")
@Scope("prototype")
public class RegisterAction extends BaseAction implements ModelDriven{
	/**
	 * 
	 */
	private static final long serialVersionUID = -2631401426454315987L;
	private User user;
	private UserRegisterInfo info=new UserRegisterInfo();
	
	public UserRegisterInfo getInfo() {
		return info;
	}

	public void setInfo(UserRegisterInfo info) {
		this.info = info;
	}

	public String registering() throws Exception {
		User u=new User();
		u.setUsername(info.getUsername());
		u.setPassword(info.getPassword());
		notice = sUser.register(u);
		if(notice.isStatus()){
			return "success";
		}else{
			return "failure";
		}
	}

	public Notice getNotice() {
		return notice;
	}

	public void setNotice(Notice notice) {
		this.notice = notice;
	}

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	@Override
	public Object getModel() {
		return info;
	}
	
	
}
